package com.geek2.supermarket.service;

import com.geek2.supermarket.dao.BillMapper;
import com.geek2.supermarket.pojo.SmbmsBill;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class BillServiceImpl implements BillService{
    @Autowired
    private BillMapper billMapper;

    @Override
    public List<SmbmsBill> queryAll(String queryProductName, int queryProviderId, int queryIsPayment, int currentPageNo, int pageSize) {
        HashMap<String, Object> map = new HashMap<String, Object>(8);
        map.put("queryProductName", queryProductName);
        map.put("queryProviderId", queryProviderId);
        map.put("queryIsPayment", queryIsPayment);
        currentPageNo=(currentPageNo-1)*pageSize;
        map.put("currentPageNo", currentPageNo);
        map.put("pageSize", pageSize);
        return billMapper.queryAll(map);
    }

    @Override
    public int getBillCount(String queryProductName, int queryProviderId, int queryIsPayment) {
        HashMap<String, Object> map = new HashMap<String, Object>(8);
        map.put("productName", queryProductName);
        map.put("providerId", queryProviderId);
        map.put("isPayment", queryIsPayment);
        System.out.println("++++++==========="+map);
        return billMapper.billCount(map);
    }


}
